package cn.edu.cug.cs.gtl.docsrv.dict.service.impl;

import cn.edu.cug.cs.gtl.docsrv.dict.dao.DictDataSourceDao;
import cn.edu.cug.cs.gtl.docsrv.dict.service.DictDataSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.stream.Collectors;

@Component
public class DictDataSourceServiceImp implements DictDataSourceService {

    @Autowired
    DictDataSourceDao dictDataSourceDao;

    @Override
    public Object getDataSources() throws Exception {
        return dictDataSourceDao.getDataSources();
    }

    @Override
    public Object getDataSourceNames() throws Exception {
        return dictDataSourceDao
                .getDataSources()
                .stream()
                .map(it->it.getDataSourceName())
                .collect(Collectors.toList());
    }
}
